<?php
/**
* Red RUgolok
* @version $Id: item.class.php
* @package RUgolok
* @subpackage item.class.php
* @author el_leo and manicon
* @copyright (C) el_leo and manicon, www.rugolok.de
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
class HTML_item {

	/**
	 * Template fuer die Darstellung eines Items
	 * @param Object $item Item, das dargestellt werden soll
	 */
	 function show($item) {
	 	global $Itemid;
	?>	

	<div class="rr_item_container">
			<h1><?=$item->title?></h1>
			<div class="rr_item_description">
				<?=$item->description?></div>
			<div class="rr_item_body">
				<?=$item->text;?>
			</div>
			
			<div class="rr_item_footer">
				<div class="rr_item_footer_body" id="rr_item_footer_body"> 
					<h1><a href="index.php?option=com_redrugolok&Itemid=<?=$Itemid?>&task=show&item_id=<?=$item->id?>"><?=$item->title?></a></h1>
					<small><?=_RR_TYPE?><?=showLinkToType($item->type_id);?></small>
					<hr>
					<div class="rr_item_date"><?=_RR_CREATED?> <?=date("d.m.y G:i", $item->date)?></div>
					<?php
					if ($item->last_update != '') { ?>
					<div class="rr_item_date"><?=_RR_UPDATED?> <?=date("d.m.y G:i", $item->last_update)?></div>
					<?php } ?>
					<hr>
					<?php
					echo _RR_AUTHORS."<br/>";
					if(is_array($item->authors)) {
						foreach($item->authors as $author) {
							echo show_username($author["jos_users_id"], $author["username"]);
							echo showLinkToAllItems($author["jos_users_id"]); 
						}
					} else {
							echo show_username($item->authors["jos_users_id"], $item->authors["username"]);
							echo showLinkToAllItems($item->authors["jos_users_id"]);
					}
					?>		
					<?=($item->inspired_by)?"<hr>Inspired by:".$item->inspired_by:"";?>
					
				</div>
				<div class="rr_item_footer_body">
					<h1><?=_RR_ITEM_TOOLS?></h1>
					<ul>
						<li><a href="#comment"><?=_RR_ITEM_COMMENT?></a></li>
						<li>edit</li>
						<li>delete</li>
					</ul>
				</div>
			</div>
		</div>
		Keywords: <?=$item->keywords?><br/>
		<div class="rr_delimiter"></div>
		<?php
	}


	 function htmlInsert($this) {
	 	global $mainframe, $Itemid, $redrugolokPath, $mosConfig_live_site, $my;
		$checkID = md5(microtime());
			?>
			<h1><?=$this->type_name; ?></h1>
			<form name="form" method="post" action="index.php?option=com_redrugolok&Itemid=<?=$Itemid?>&task=add">
				<input type="hidden" name="type_id" id="type_id" value="<?=$this->type_id; ?>">
				<input type="hidden" name="submited" id="submited" value="fillOut">
				<input type="hidden" name="checkID" id="checkID" value="<?=$checkID?>">
				<input type="hidden" name="authors" id="authors" value="<?=$my->id?>">
				<fieldset class="fieldset">
					<legend class="legend"><?=_RR_LEGEND_GENERAL;?></legend>
					<div class="fieldname"><?=_RR_TITLE; ?></div> <input type="text" name="title" id="title" value="<?=(isset($_POST["title"]))?$_POST["title"]:'';?>" maxlegth="64"><a title="<?=_RR_TRANSLIT_THIS?>" href="javascript:;" onClick="lat_to_rus(name);"><img src="<?=$mosConfig_live_site?>/images/icons/lat_to_cyr.gif" style="border:0px; height:20px; width:20px; margin-top:2px;" alt="<?=_RR_TRANSLIT_THIS?>" /></a><img src="<?=$redrugolokPath?>/images/help.jpg" class="helpimage" onfocus="return overlib('<?=_RR_TITLE_HELP; ?>', CAPICON, RIGHT);" onmouseout="return nd();"><br/>
					<div class="fieldname"><?=_RR_DESCRIPTION; ?></div> <textarea name="description" id="description" cols="40" rows="7"><?=(isset($_POST["description"]))?$_POST["description"]:'';?></textarea><a title="<?=_RR_TRANSLIT_THIS?>" href="javascript:;" onClick="lat_to_rus(description);"><img src="<?=$mosConfig_live_site?>/images/icons/lat_to_cyr.gif" style="border:0px; height:20px; width:20px; margin-top:2px;" alt="<?=_RR_TRANSLIT_THIS?>" /></a><img src="<?=$redrugolokPath?>/images/help.jpg" class="helpimage" onfocus="return overlib('<?=_RR_DESCRIPTION_HELP; ?>', CAPICON, RIGHT);" onmouseout="return nd();"><br/>
				</fieldset>
				<fieldset class="fieldset">
					<legend class="legend"><?=_RR_LEGEND_ITEM;?></legend>
					<?php /* Je nach Typ wird ein Feld ausgewaehlt */
						switch($this->type_id) {
							// type image
							case '3': ?> <input type="file" name="filename" id="filename" value="" size="32"><img src="<?=$redrugolokPath?>/images/help.jpg" class="helpimage" onfocus="return overlib('<?=_RR_ITEM_HELP; ?>', CAPICON, RIGHT);" onmouseout="return nd();">
							<?php break;
							// type text
							default: ?> <textarea name="text" id="text" cols="50" rows="10"><?=(isset($_POST["text"]))?$_POST["text"]:'';?></textarea><a title="<?=_RR_TRANSLIT_THIS?>" href="javascript:;" onClick="lat_to_rus(item);"><img src="<?=$mosConfig_live_site?>/images/icons/lat_to_cyr.gif" style="border:0px; height:20px; width:20px; margin-top:2px;" alt="<?=_RR_TRANSLIT_THIS?>" /></a><img src="<?=$redrugolokPath?>/images/help.jpg" class="helpimage" onfocus="return overlib('<?=_RR_ITEM_HELP; ?>', CAPICON, RIGHT);" onmouseout="return nd();">
							<?php break;
					 } ?>
				</fieldset>

				<fieldset class="fieldset">
					<legend class="legend"><?=_RR_LEGEND_OPTIONS;?></legend>
					<div class="fieldname"><?=_RR_KEYWORDS; ?></div> <input type="text" name="keywords" id="keywords" value="<?=(isset($_POST["keywords"]))?$_POST["keywords"]:'';?>" maxlegth="256"><a title="<?=_RR_TRANSLIT_THIS?>" href="javascript:;" onClick="lat_to_rus(keywords);"><img src="<?=$mosConfig_live_site?>/images/icons/lat_to_cyr.gif" style="border:0px; height:20px; width:20px; margin-top:2px;" alt="<?=_RR_TRANSLIT_THIS?>" /></a><img src="<?=$redrugolokPath?>/images/help.jpg" class="helpimage" onfocus="return overlib('<?=_RR_KEYWORDS_HELP; ?>', CAPICON, RIGHT);" onmouseout="return nd();"><br/>
					<div class="fieldname"><?=_RR_INSPIREDBY; ?></div> <input type="text" name="inspiredby" id="inspiredby" value="<?=(isset($_POST["inspiredby"]))?$_POST["inspiredby"]:'';?>" maxlegth="256"><a title="<?=_RR_TRANSLIT_THIS?>" href="javascript:;" onClick="lat_to_rus(inspiredby);"><img src="<?=$mosConfig_live_site?>/images/icons/lat_to_cyr.gif" style="border:0px; height:20px; width:20px; margin-top:2px;" alt="<?=_RR_TRANSLIT_THIS?>" /></a><img src="<?=$redrugolokPath?>/images/help.jpg" class="helpimage" onfocus="return overlib('<?=_RR_INSPIREDBY_HELP; ?>', CAPICON, RIGHT);" onmouseout="return nd();"><br/>
					<div class="fieldname"><?=_RR_SHOWME; ?></div> <input type="checkbox" name="showme" id="showme" value="1" <?=(isset($_POST["showme"]) and ($_POST["showme"] == 0))? '' : 'checked';?>><img src="<?=$redrugolokPath?>/images/help.jpg" class="helpimage" onfocus="return overlib('<?=_RR_SHOWME_HELP; ?>', CAPICON, RIGHT);" onmouseout="return nd();"><br/>
					<div class="fieldname"><?=_RR_RATEME; ?></div> <input type="checkbox" name="rateme" id="rateme" value="1" <?=(isset($_POST["rateme"]) and ($_POST["rateme"] == 0))? '' : 'checked';?>><img src="<?=$redrugolokPath?>/images/help.jpg" class="helpimage" onfocus="return overlib('<?=_RR_RATEME_HELP; ?>', CAPICON, RIGHT);" onmouseout="return nd();"><br/>
				</fieldset>
				<br/>
				<input type="submit" name="submit" id="submit" value="<?=_RR_SAVE; ?>">
			</form>
		<?php
	 }
	 
	 
function htmlUpdate($item) {
	 	global $mainframe, $Itemid, $redrugolokPath, $mosConfig_live_site, $my;
	 		 	
	 	?>
			<h1><?=$item->type_name; ?></h1>
			<form name="form" method="post" action="index.php?option=com_redrugolok&Itemid=<?=$Itemid?>&task=editItem">
				<input type="hidden" name="type_id" id="type_id" value="<?=$item->type_id; ?>">
				<input type="hidden" name="submited" id="submited" value="fillOut">
				<?php
				print_r($item->authors);
				foreach($item->authors as $author) {
				?>
				<input type="hidden" name="authors[]" id="authors" value="<?=$author?>">
				<?php } ?>
				<input type="hidden" name="item_id" id="item_id" value="<?=$item->id?>">
				<fieldset class="fieldset">
					<legend class="legend"><?=_RR_LEGEND_GENERAL;?></legend>
					<div class="fieldname"><?=_RR_TITLE; ?></div> <input type="text" name="title" id="title" value="<?=$item->title?>" maxlegth="64"><a title="<?=_RR_TRANSLIT_THIS?>" href="javascript:;" onClick="lat_to_rus(name);"><img src="<?=$mosConfig_live_site?>/images/icons/lat_to_cyr.gif" style="border:0px; height:20px; width:20px; margin-top:2px;" alt="<?=_RR_TRANSLIT_THIS?>" /></a><img src="<?=$redrugolokPath?>/images/help.jpg" class="helpimage" onfocus="return overlib('<?=_RR_TITLE_HELP; ?>', CAPICON, RIGHT);" onmouseout="return nd();"><br/>
					<div class="fieldname"><?=_RR_DESCRIPTION; ?></div> <textarea name="description" id="description" cols="40" rows="7"><?=$item->description?></textarea><a title="<?=_RR_TRANSLIT_THIS?>" href="javascript:;" onClick="lat_to_rus(description);"><img src="<?=$mosConfig_live_site?>/images/icons/lat_to_cyr.gif" style="border:0px; height:20px; width:20px; margin-top:2px;" alt="<?=_RR_TRANSLIT_THIS?>" /></a><img src="<?=$redrugolokPath?>/images/help.jpg" class="helpimage" onfocus="return overlib('<?=_RR_DESCRIPTION_HELP; ?>', CAPICON, RIGHT);" onmouseout="return nd();"><br/>
				</fieldset>
				<fieldset class="fieldset">
					<legend class="legend"><?=_RR_LEGEND_ITEM;?></legend>
					<?php /* Je nach Typ wird ein Feld ausgewaehlt */
						switch($item->type_id) {
							// type image
							case '3': ?> <input type="file" name="filename" id="filename" value="" size="32"><img src="<?=$redrugolokPath?>/images/help.jpg" class="helpimage" onfocus="return overlib('<?=_RR_ITEM_HELP; ?>', CAPICON, RIGHT);" onmouseout="return nd();">
							<?php break;
							// type text
							default: ?> <textarea name="text" id="text" cols="50" rows="10"  mce_editable="true" class="mceEditor"><?=$item->text?></textarea><a title="<?=_RR_TRANSLIT_THIS?>" href="javascript:;" onClick="lat_to_rus(item);"><img src="<?=$mosConfig_live_site?>/images/icons/lat_to_cyr.gif" style="border:0px; height:20px; width:20px; margin-top:2px;" alt="<?=_RR_TRANSLIT_THIS?>" /></a><img src="<?=$redrugolokPath?>/images/help.jpg" class="helpimage" onfocus="return overlib('<?=_RR_ITEM_HELP; ?>', CAPICON, RIGHT);" onmouseout="return nd();">
							<?php break;
					 } ?>
				</fieldset>

				<fieldset class="fieldset">
					<legend class="legend"><?=_RR_LEGEND_OPTIONS;?></legend>
					<div class="fieldname"><?=_RR_KEYWORDS; ?></div> <input type="text" name="keywords" id="keywords" value="<?=$item->keywords?>" maxlegth="256"><a title="<?=_RR_TRANSLIT_THIS?>" href="javascript:;" onClick="lat_to_rus(keywords);"><img src="<?=$mosConfig_live_site?>/images/icons/lat_to_cyr.gif" style="border:0px; height:20px; width:20px; margin-top:2px;" alt="<?=_RR_TRANSLIT_THIS?>" /></a><img src="<?=$redrugolokPath?>/images/help.jpg" class="helpimage" onfocus="return overlib('<?=_RR_KEYWORDS_HELP; ?>', CAPICON, RIGHT);" onmouseout="return nd();"><br/>
					<div class="fieldname"><?=_RR_INSPIREDBY; ?></div> <input type="text" name="inspiredby" id="inspiredby" value="<?=$item->inspired_by?>" maxlegth="256"><a title="<?=_RR_TRANSLIT_THIS?>" href="javascript:;" onClick="lat_to_rus(inspiredby);"><img src="<?=$mosConfig_live_site?>/images/icons/lat_to_cyr.gif" style="border:0px; height:20px; width:20px; margin-top:2px;" alt="<?=_RR_TRANSLIT_THIS?>" /></a><img src="<?=$redrugolokPath?>/images/help.jpg" class="helpimage" onfocus="return overlib('<?=_RR_INSPIREDBY_HELP; ?>', CAPICON, RIGHT);" onmouseout="return nd();"><br/>
					<div class="fieldname"><?=_RR_SHOWME; ?></div> <input type="checkbox" name="showme" id="showme" value="1" <?=(!$item->published)? '' : 'checked';?>><img src="<?=$redrugolokPath?>/images/help.jpg" class="helpimage" onfocus="return overlib('<?=_RR_SHOWME_HELP; ?>', CAPICON, RIGHT);" onmouseout="return nd();"><br/>
					<!-- <div class="fieldname"><?=_RR_RATEME; ?></div> <input type="checkbox" name="rateme" id="rateme" value="1" <?=(!$item->rated)? '' : 'checked';?>><img src="<?=$redrugolokPath?>/images/help.jpg" class="helpimage" onfocus="return overlib('<?=_RR_RATEME_HELP; ?>', CAPICON, RIGHT);" onmouseout="return nd();"><br/>-->
				</fieldset> 
				<br/>
				<input type="submit" name="submit" id="submit" value="<?=_RR_SAVE; ?>">
			</form>
		<?php
	 }

}
?>
